//
//  SKFoodTopCell.m
//  Gastrosoph
//
//  Created by 张明磊 on 12-10-31.
//
//

#import "SKFoodTopCell.h"
#import "SKModel_foodTopRank.h"
#import "SKHeaderFiles.h"
#import "SKModel_tourist.h"
#import "SKFoodDetailViewController.h"


#define SK_FOODTOPCELL_RECT CGRectMake(0, 0, 320, 450)

#define SK_IMAGEVIEW_BACKGROUND_RECT CGRectMake(3, 0, 314, 308)

#define SK_IMAGEVIEW_FOODIMAGE_RECT CGRectMake(6, 6, 301, 240)

#define SK_BUTTON_FOODIMAGE_RECT CGRectMake(9, 46, 301, 200)

#define SK_IMAGEVIEW_BACKGROUNDTOP_RECT CGRectMake(0, 0, 301, 39)

#define SK_IMAGEVIEW_HEADPORTRAIT_RECT CGRectMake(3, 3, 33, 33)

#define SK_LABEL_FOODNAME_RECT CGRectMake(40, 3, 120, 18)

#define SK_LABEL_USERNAME_RECT CGRectMake(40, 22, 60, 18)

#define SK_LABEL_TIME_RECT CGRectMake(110, 22, 60, 18)

#define SK_IMAGEVIEW_LOCATION_RECT CGRectMake(12, 247, 10, 14)

#define SK_LABEL_RESTAURANTNAME_RECT CGRectMake(30, 247, 120, 14)

#define SK_LABEL_DISTANCE_RECT CGRectMake(160, 247, 60, 14)

#define SK_BUTTON_WANTEAT_RECT CGRectMake(20, 270, 67, 26)

#define SK_BUTTON_COMMENT_RECT CGRectMake(92, 270, 67, 26)

#define SK_LABEL_WANTEAT_RECT CGRectMake(23, 0, 37, 26)

#define SK_LABEL_COMMENT_RECT CGRectMake(23, 0, 37, 26)

#define SK_BUTTON_MORE_RECT CGRectMake(260, 270, 40, 26)

#define SK_IMAGEVIEW_WANTEAT_RECT CGRectMake(9, 310, 15, 15)

#define SK_LABEL_WANTEATCOUNT_RECT CGRectMake(11, 330, 30, 15)

#define SK_IMAGEVIEW_COMMENT_RECT CGRectMake(9, 355, 15, 15)

#define SK_LABEL_COMMENTCOUNT_RECT CGRectMake(11, 370, 30, 15)

#define SK_SCROLLVIEW_OTHERUSER_RECT CGRectMake(30, 307, 220, 40)

#define SK_IMAGEVIEW_RIGHTARROW_RECT CGRectMake(290, 320, 10, 15)




typedef enum
{
    SK_expandButton_tag_love  = 0,
    
    SK_expandButton_tag_like     ,
    
    SK_expandButton_tag_general  ,
    
    SK_expandButton_tag_noMyMenu ,
    
}SK_expandButton_tag;


@implementation SKFoodTopCell

@synthesize model_foodTopRank = _model_foodTopRank;

@synthesize buttonBar = _buttonBar;

@synthesize integer_commentLableY = _integer_commentLableY;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier withModel:(SKModel_foodTopRank *)_model
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self)
    {
        [self setFrame:SK_FOODTOPCELL_RECT];
        
        _model_foodTopRank = _model;
        
        [self install_cell_foodTopRank];
        
        [self install_cell_expandButton];
        
        [self install_cell_likeEatView];
        
        if(_model_foodTopRank.integer_commentCount != 0)
        {
            [self install_cell_commentView];
        }
        // Initialization code
    }
    
    return self;
}

- (id)initwithModel:(SKModel_foodTopRank *)_model
{
    self = [super init];
    
    if(self)
    {
        [self setFrame:SK_FOODTOPCELL_RECT];
        
        _model_foodTopRank = _model;
        
        [self install_cell_foodTopRank];
        
        [self install_cell_expandButton];
        
        [self install_cell_likeEatView];
        
        if(_model_foodTopRank.integer_commentCount != 0)
        {
            [self install_cell_commentView];
        }
    }
    
    return self;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)dealloc
{
    [_model_foodTopRank release], _model_foodTopRank = nil;
    
    [_buttonBar release], _buttonBar = nil;
    
    [super dealloc];
}

- (void)install_cell_foodTopRank
{
    UIImageView *imageView_background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_foodTop_background.png"]];
    
    [imageView_background setFrame:SK_IMAGEVIEW_BACKGROUND_RECT];
    
    [self addSubview:imageView_background];
    
    [imageView_background release];

    UIButton *button_foodImage = [UIButton buttonWithType:UIButtonTypeCustom];
                                  
    [button_foodImage setFrame:SK_BUTTON_FOODIMAGE_RECT];
                                  
    [button_foodImage addTarget:self action:@selector(didClickButton_foodImageWithModel) forControlEvents:UIControlEventTouchUpInside];
    
    [button_foodImage setShowsTouchWhenHighlighted:YES];
    
    [self addSubview:button_foodImage];
 
    UIImageView *imageView_foodImage = [[UIImageView alloc]initWithFrame:SK_IMAGEVIEW_FOODIMAGE_RECT];
    
    [imageView_foodImage setImage:_model_foodTopRank.image_food];
    
    [imageView_background addSubview:imageView_foodImage];
    
    [imageView_foodImage release];
    
    UIImageView *imageView_backgroundTop = [[UIImageView alloc] initWithFrame:SK_IMAGEVIEW_BACKGROUNDTOP_RECT];

    [imageView_backgroundTop setImage:[UIImage imageNamed:@"cell_foodTop_backgroundTop.png"]];
    
    [imageView_foodImage addSubview:imageView_backgroundTop];
    
    [imageView_backgroundTop release];
    
    UIImageView *imageView_headPortrait = [[UIImageView alloc] initWithFrame:SK_IMAGEVIEW_HEADPORTRAIT_RECT];
    
    [imageView_headPortrait setImage:_model_foodTopRank.image_share_userHeadPortrait];
    
    [imageView_backgroundTop addSubview:imageView_headPortrait];
    
    [imageView_headPortrait release];
    
    UILabel *label_foodName = [[UILabel alloc] initWithFrame:SK_LABEL_FOODNAME_RECT];
    
    [label_foodName setBackgroundColor:[UIColor clearColor]];
    
    [label_foodName setTextColor:[UIColor blackColor]];

    [label_foodName setFont:[UIFont fontWithName:SK_TEXTFONT size:18.0]];
    
    [label_foodName setText:_model_foodTopRank.string_foodName];
    
    [imageView_backgroundTop addSubview:label_foodName];
    
    [label_foodName release];
    
    UILabel *label_userName = [[UILabel alloc] initWithFrame:SK_LABEL_USERNAME_RECT];
    
    [label_userName setBackgroundColor:[UIColor clearColor]];
    
    [label_userName setTextColor:[UIColor grayColor]];
    
    [label_userName setFont:[UIFont fontWithName:SK_TEXTFONT size:13.0]];
    
    [label_userName setText:_model_foodTopRank.string_share_userName];
    
    [imageView_backgroundTop addSubview:label_userName];
    
    [label_userName release];
    
    UILabel *label_time = [[UILabel alloc] initWithFrame:SK_LABEL_TIME_RECT];
    
    [label_time setBackgroundColor:[UIColor clearColor]];
    
    [label_time setTextColor:[UIColor grayColor]];
    
    [label_time setFont:[UIFont fontWithName:SK_TEXTFONT size:13.0]];
    
    [label_time setText:_model_foodTopRank.string_share_time];
    
    [imageView_backgroundTop addSubview:label_time];
    
    [label_time release];
    
    UIImageView *imageView_location = [[UIImageView alloc] initWithFrame:SK_IMAGEVIEW_LOCATION_RECT];
    
    [imageView_location setImage:[UIImage imageNamed: @"imageVIew_cell_location.png"]];
    
    [imageView_background addSubview:imageView_location];
    
    [imageView_location release];
    
    UILabel *label_restaurantName = [[UILabel alloc] initWithFrame:SK_LABEL_RESTAURANTNAME_RECT];
    
    [label_restaurantName setTextColor:[UIColor grayColor]];
    
    [label_restaurantName setBackgroundColor:[UIColor clearColor]];
    
    [label_restaurantName setFont:[UIFont fontWithName:SK_TEXTFONT size:13.0]];
    
    [label_restaurantName setText:_model_foodTopRank.string_restaurantName];
    
    [imageView_background addSubview:label_restaurantName];
    
    [label_restaurantName release];
    
    UILabel *label_distance = [[UILabel alloc] initWithFrame:SK_LABEL_DISTANCE_RECT];
    
    [label_distance setTextColor:[UIColor grayColor]];
    
    [label_distance setBackgroundColor:[UIColor clearColor]];
    
    [label_distance setFont:[UIFont fontWithName:SK_TEXTFONT size:13.0]];
    
    [label_distance setText:_model_foodTopRank.string_distance];
    
    [imageView_background addSubview:label_distance];
    
    [label_distance release];
    
    UIButton *button_wantEat = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_wantEat setFrame:SK_BUTTON_WANTEAT_RECT];
    
    [button_wantEat setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_wantEat.png"] forState:UIControlStateNormal];
    
    [button_wantEat setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_wantEat_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_wantEat addTarget:self action:@selector(didClickButton_wantEat) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *label_wantEat = [[UILabel alloc] initWithFrame:SK_LABEL_WANTEAT_RECT];
    
    [label_wantEat setFont:[UIFont fontWithName:SK_TEXTFONT size:15.0]];
    
    [label_wantEat setTextColor:[UIColor grayColor]];
    
    [label_wantEat setTextAlignment:NSTextAlignmentRight];
    
    [label_wantEat setText:@"想吃"];
    
    [label_wantEat setBackgroundColor:[UIColor clearColor]];
    
    [button_wantEat addSubview:label_wantEat];
    
    [label_wantEat release];
    
    [self addSubview:button_wantEat];
    
    UIButton *button_comment = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_comment setFrame:SK_BUTTON_COMMENT_RECT];
    
    [button_comment setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_comment.png"] forState:UIControlStateNormal];
    
    [button_comment setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_comment_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_comment addTarget:self action:@selector(didClickButton_comment) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *label_comment = [[UILabel alloc] initWithFrame:SK_LABEL_COMMENT_RECT];
    
    [label_comment setFont:[UIFont fontWithName:SK_TEXTFONT size:15.0]];
    
    [label_comment setTextColor:[UIColor grayColor]];
    
    [label_comment setTextAlignment:NSTextAlignmentRight];
    
    [label_comment setText:@"评论"];
    
    [label_comment setBackgroundColor:[UIColor clearColor]];
    
    [button_comment addSubview:label_comment];
    
    [label_comment release];
    
    [self addSubview:button_comment];
    
    UIButton *button_more = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_more setFrame:SK_BUTTON_MORE_RECT];
    
    [button_more setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_more.png"] forState:UIControlStateNormal];
    
    [button_more setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_more_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_more addTarget:self action:@selector(didClickButton_more) forControlEvents:UIControlEventTouchUpInside];
        
    [self addSubview:button_more];
}

- (void)install_cell_expandButton
{
    CGRect expandButtonFrame = CGRectMake(0, 0, 71.5, 47);
    
    CGPoint center = CGPointMake(230, 10);
    
    UIButton *button_love = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_love setImage:[UIImage imageNamed:@"expandButton_love.png"] forState:UIControlStateNormal];
    
    [button_love setImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_love setFrame:expandButtonFrame];
    
    [button_love setTag:SK_expandButton_tag_love];
    
    [button_love addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button_like = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_like setImage:[UIImage imageNamed:@"expandButton_like.png"] forState:UIControlStateNormal];
    
    [button_like setImage:[UIImage imageNamed:@"expandButton_like_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_like setFrame:expandButtonFrame];
    
    [button_like setTag:SK_expandButton_tag_like];
    
    [button_like addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button_general = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_general setImage:[UIImage imageNamed:@"expandButton_general.png"] forState:UIControlStateNormal];
    
    [button_general setImage:[UIImage imageNamed:@"expandButton_general_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_general setFrame:expandButtonFrame];
    
    [button_general setTag:SK_expandButton_tag_general];
    
    [button_general addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button_noMyMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_noMyMenu setFrame:expandButtonFrame];
    
    [button_noMyMenu setImage:[UIImage imageNamed:@"expandButton_noMyMenu.png"] forState:UIControlStateNormal];
    
    [button_noMyMenu setImage:[UIImage imageNamed:@"expandButton_noMyMenu_pressed.png"] forState:UIControlStateHighlighted];

    [button_noMyMenu setTag:SK_expandButton_tag_noMyMenu];
    
    [button_noMyMenu addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    NSArray *buttons = [NSArray arrayWithObjects:button_noMyMenu,button_general,button_like,button_love,nil];
    
    switch (_model_foodTopRank.integer_foodRate)
    {
        case 0:
        {
            self.buttonBar = [[[RNExpandingButtonBar alloc]
                               initWithImage:[UIImage imageNamed:@"expandButton_top_love.png"] selectedImage:[UIImage imageNamed:@"expandButton_top_love.png"] toggledImage:[UIImage imageNamed:@"expandButton_love.png"] toggledSelectedImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] buttons:buttons center:center] autorelease];
            
            break;
        }
            
        case 1:
        {
            self.buttonBar = [[[RNExpandingButtonBar alloc]
                               initWithImage:[UIImage imageNamed:@"expandButton_top_like.png"] selectedImage:[UIImage imageNamed:@"expandButton_top_like.png"] toggledImage:[UIImage imageNamed:@"expandButton_love.png"] toggledSelectedImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] buttons:buttons center:center] autorelease];
            break;
        }
            
        case 2:
        {
            self.buttonBar = [[[RNExpandingButtonBar alloc]
                               initWithImage:[UIImage imageNamed:@"expandButton_top_general.png"] selectedImage:[UIImage imageNamed:@"expandButton_top_general.png"] toggledImage:[UIImage imageNamed:@"expandButton_love.png"] toggledSelectedImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] buttons:buttons center:center] autorelease];
            break;
        }
            
        default:
            break;
    }
    
    [self addSubview:_buttonBar];
    
}


- (void)install_cell_likeEatView
{
    UIImageView *image_likeEat = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageView_wantEat.png"]];
    
    [image_likeEat setFrame:SK_IMAGEVIEW_WANTEAT_RECT];
    
    [self addSubview:image_likeEat];
    
    [image_likeEat release];
    
    UILabel *label_likeEatCount = [[UILabel alloc] initWithFrame:SK_LABEL_WANTEATCOUNT_RECT];
    
    [label_likeEatCount setTextColor:[UIColor grayColor]];
    
    [label_likeEatCount setBackgroundColor:[UIColor clearColor]];
    
    [label_likeEatCount setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    [label_likeEatCount setText:[NSString stringWithFormat:@"%d",_model_foodTopRank.integer_wantEatCount ]];
    
    [self addSubview:label_likeEatCount];
    
    [label_likeEatCount release];
    
    UIImageView *image_comment = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageView_comment.png"]];
    
    [image_comment setFrame:SK_IMAGEVIEW_COMMENT_RECT];
    
    [self addSubview:image_comment];
    
    [image_comment release];
    
    UILabel *label_commentCount = [[UILabel alloc] initWithFrame:SK_LABEL_COMMENTCOUNT_RECT];
    
    [label_commentCount setTextColor:[UIColor grayColor]];
    
    [label_commentCount setBackgroundColor:[UIColor clearColor]];
    
    [label_commentCount setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    [label_commentCount setText:[NSString stringWithFormat:@"%d",_model_foodTopRank.integer_commentCount]];
    
    [self addSubview:label_commentCount];
    
    [label_commentCount release];
    
    UIScrollView *scrollView_otherUser = [[UIScrollView alloc] initWithFrame:SK_SCROLLVIEW_OTHERUSER_RECT];
    
    [scrollView_otherUser setBackgroundColor:[UIColor clearColor]];
    
    for(int i = 0; i < _model_foodTopRank.integer_wantEatCount; i++)
    {
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"test_user_%d.png", i + 1]] forState:UIControlStateNormal];
        
        button.frame = CGRectMake(10 + i*(33 + 10), 5.0f, 33.0f, 33.0f);
        
        button.tag = i;
        
		[scrollView_otherUser addSubview:button];
	}
    
	[scrollView_otherUser setContentSize:CGSizeMake(10 + 10 +_model_foodTopRank.integer_wantEatCount*(33+10), 40.0)];
    
    [self addSubview:scrollView_otherUser];
    
    [scrollView_otherUser release];
    
    if(_model_foodTopRank.integer_wantEatCount > 5)
    {
        UIImageView *imageView_rightArrow = [[UIImageView alloc] initWithFrame:SK_IMAGEVIEW_RIGHTARROW_RECT];
    
        [imageView_rightArrow setImage:[UIImage     imageNamed:@"cell_imageView_rightArrow.png"]];
    
        [self addSubview:imageView_rightArrow];
     
        [imageView_rightArrow release];
    }
}

- (void)install_cell_commentView
{
    if(_model_foodTopRank.integer_commentCount < 4)
    {
        for (int i = 0; i < _model_foodTopRank.integer_commentCount;i++)
        {
            UIButton *button_tourist = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [button_tourist setFrame:CGRectMake(40, 350 + self.integer_commentLableY, 10, 20)];
            
            [button_tourist setTag:i];
            
            [button_tourist addTarget:self action:@selector(didClickButton_touristName:) forControlEvents:UIControlEventTouchUpInside];
            
            SKModel_tourist *tourist_tmp = [_model_foodTopRank.array_touristArray objectAtIndex:i];
            
            [button_tourist.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
            
            button_tourist.titleLabel.numberOfLines = 0;
            
            CGSize button_size = [tourist_tmp.string_touristName sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(115.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
            
            CGRect button_rect = button_tourist.frame;
            
            button_rect.size = button_size;
            
            [button_tourist setFrame:button_rect];
            
            [button_tourist setTitle:tourist_tmp.string_touristName forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
            
            [self addSubview:button_tourist];
            
            UILabel *label_tourist = [[UILabel alloc] initWithFrame:CGRectMake(button_tourist.frame.origin.x + button_tourist.frame.size.width, button_tourist.frame.origin.y, 200, 20)];
            
            [label_tourist setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
            
            CGSize labelSize = [tourist_tmp.string_touristComment sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(200.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
            
            label_tourist.numberOfLines = 0;
            
            CGRect labelRect = label_tourist.frame;
            
            labelRect.size = labelSize;
            
            [label_tourist setFrame:labelRect];
            
            [label_tourist setBackgroundColor:[UIColor clearColor]];
            
            [label_tourist setTextColor:[UIColor grayColor]];
            
            [label_tourist setText:tourist_tmp.string_touristComment];
            
            [self addSubview:label_tourist];
            
            [label_tourist release];
            
            if(label_tourist.frame.size.height >= button_tourist.frame.size.height)
            {
                self.integer_commentLableY += label_tourist.frame.size.height + 7;
            }
            
            else
            {
                self.integer_commentLableY += button_tourist.frame.size.height + 7;
            }
        }
    }
    
    else
    {
        for (int i = 0; i < 3;i++)
        {
            UIButton *button_tourist = [UIButton buttonWithType:UIButtonTypeCustom];
        
            [button_tourist setFrame:CGRectMake(40, 350 + self.integer_commentLableY, 10, 20)];
        
            [button_tourist setTag:i];
        
            [button_tourist addTarget:self action:@selector(didClickButton_touristName:) forControlEvents:UIControlEventTouchUpInside];
        
            SKModel_tourist *tourist_tmp = [_model_foodTopRank.array_touristArray objectAtIndex:i];
            
            [button_tourist.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
        
            button_tourist.titleLabel.numberOfLines = 0;
        
            CGSize button_size = [tourist_tmp.string_touristName sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(115.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
        
            CGRect button_rect = button_tourist.frame;
            
            button_rect.size = button_size;
        
            [button_tourist setFrame:button_rect];
        
            [button_tourist setTitle:tourist_tmp.string_touristName forState:UIControlStateNormal];
        
            [button_tourist setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
        
            [self addSubview:button_tourist];
            
            UILabel *label_tourist = [[UILabel alloc] initWithFrame:CGRectMake(button_tourist.frame.origin.x + button_tourist.frame.size.width, button_tourist.frame.origin.y, 200, 20)];
        
            [label_tourist setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
        
            CGSize labelSize = [tourist_tmp.string_touristComment sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(200.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
        
            label_tourist.numberOfLines = 0;
        
            CGRect labelRect = label_tourist.frame;
        
            labelRect.size = labelSize;
        
            [label_tourist setFrame:labelRect];

            [label_tourist setBackgroundColor:[UIColor clearColor]];
        
            [label_tourist setTextColor:[UIColor grayColor]];
        
            [label_tourist setText:tourist_tmp.string_touristComment];
        
            [self addSubview:label_tourist];
        
            [label_tourist release];
            
            if(label_tourist.frame.size.height >= button_tourist.frame.size.height)
            {
                self.integer_commentLableY += label_tourist.frame.size.height + 7;
            }
            
            else
            {
                self.integer_commentLableY += button_tourist.frame.size.height + 7;
            }
        }
        
        UIButton *button_showAllComment = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [button_showAllComment setFrame:CGRectMake(20, 350 + self.integer_commentLableY, 150, 20)];
        
        [button_showAllComment addTarget:self action:@selector(didClickButton_showAlltourist:) forControlEvents:UIControlEventTouchUpInside];
        
        [button_showAllComment setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [button_showAllComment setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
        
        [button_showAllComment.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:14.0f]];
        
        [button_showAllComment setTitle:[NSString stringWithFormat:@"查看全部%d条评论",_model_foodTopRank.integer_commentCount] forState:UIControlStateNormal];
        
        [self addSubview:button_showAllComment];
    }
}


#pragma mark - 
#pragma mark DidClickCellButton

- (void)didClickButton_wantEat
{
   
}

- (void)didClickButton_comment
{
    
}

- (void)didClickButton_more
{
    
}


- (void)didClickButton_foodImageWithModel
{
    SKFoodDetailViewController *foodDetailController = [[SKFoodDetailViewController alloc] initWithModel:_model_foodTopRank];
    
    UIViewController *viewController = [self reciveSuperViewControllerWithView:self];
    
    [viewController presentViewController:foodDetailController animated:NO completion:nil];
    
    [foodDetailController release];
}



#pragma mark -
#pragma mark InstallExpandButton

- (void)didClickExpandButton:(id)sender
{
    UIButton *expandButton = (UIButton *)sender;
    
    switch (expandButton.tag)
    {
        case SK_expandButton_tag_love:
        {
            [_buttonBar hideButtonsAnimated:YES];
            
            break;
        }
        
        case SK_expandButton_tag_like:
        {
            [_buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        case SK_expandButton_tag_general:
        {
            [_buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        case SK_expandButton_tag_noMyMenu:
        {
            [_buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        default:
            break;
    }
}


#pragma mark -
#pragma mark InstallTouristNameButton

- (void)didClickButton_touristName:(id)sender
{
    
}
    
- (void)didClickButton_showAlltourist:(id)sender
{
   
}


#pragma mark -
#pragma mark ReciveSuperViewController

- (UIViewController *)reciveSuperViewControllerWithView:(UIView *)view
{
    for (UIView *next = [view superview]; next; next = next.superview)
    {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]])
        {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}




@end
